package greate.project;

import lombok.extern.slf4j.Slf4j;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

/**
 * @author v_zhangshun01
 */
@Slf4j
public class App {

    public static void main(String[] args) throws Exception {

        // 创建默认上下文
        CamelContext context = new DefaultCamelContext();

        // 现开启想表达的是 ， camel 在开启后可以动态的新增和关闭路由。
        context.start();

        // 新增路由
        context.addRoutes(new HelloWorldRoute());

        synchronized (App.class){
            App.class.wait();
        }

    }

    static class HelloWorldRoute extends RouteBuilder {
        @Override
        public void configure() throws Exception {
            System.out.println("hello world.");
            from("cron:foo?schedule=*+*+*+*+*+?")
            .process(exchange -> {
                Thread.sleep(3000);
                System.out.println("123");
            });
        }
    }

}
